package jp.sourceforge.akjrcp.util;

public class ProcessTimeoutDestroyer extends Thread{
private Process process;
private long lasttime=System.currentTimeMillis();
private int timeout;
private boolean monitering=true;
private int sleeptime=1000*10;
private boolean destroy=false;

public boolean isDestroy() {
	return destroy;
}


public void setDestroy(boolean destroy) {
	this.destroy = destroy;
}


public void run(){
	while(monitering){
		
		if(System.currentTimeMillis()>lasttime+timeout){
			if(destroy && process!=null){
				//log.info("process destroy by ProcessTimeoutDestroyer");
				process.destroy();
			}
		}
		
		try {
			Thread.sleep(sleeptime);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}


public long getLasttime() {
	return lasttime;
}


public void setLasttime(long lasttime) {
	this.lasttime = lasttime;
}


public boolean isMonitering() {
	return monitering;
}


public void setMonitering(boolean monitering) {
	this.monitering = monitering;
}


public Process getProcess() {
	return process;
}


public void setProcess(Process process) {
	this.process = process;
}


public int getSleeptime() {
	return sleeptime;
}


public void setSleeptime(int sleeptime) {
	this.sleeptime = sleeptime;
}


public int getTimeout() {
	return timeout;
}


public void setTimeout(int timeout) {
	this.timeout = timeout;
}

}
